home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / Pict2Ascii 1.03 / Panes / CGWorldPane.cp < prev    next >
Encoding:
Text File  |  1997-05-19  |  2.1 KB  |  80 lines  |  [TEXT/CWIE]

  1. // =================================================================================
  2. //    CGWorldPane.cp                             ©1997 BB's Team Inc. All rights reserved
  3. // =================================================================================
  4. #include "PL_Utils.h"
  5. #include "CGWorldPane.h"
  6.  
  7. #include "UDrawingState.h"
  8.  
  9.  
  10. // ---------------------------------------------------------------------------------
  11. //        • CreateGWorldPaneStream [static]
  12. // ---------------------------------------------------------------------------------
  13.  
  14. CGWorldPane *
  15. CGWorldPane::CreateGWorldPaneStream(
  16.     LStream    *inStream )
  17. {
  18.     return new CGWorldPane (inStream);
  19. }
  20.  
  21.  
  22. // ---------------------------------------------------------------------------------
  23. //        • CGWorldPane(LStream*)
  24. // ---------------------------------------------------------------------------------
  25.  
  26. CGWorldPane::CGWorldPane (LStream *inStream )
  27.     : LPane (inStream), mGW(nil)
  28. {
  29. }
  30.  
  31.  
  32. // ---------------------------------------------------------------------------------
  33. //        • ~CGWorldPane
  34. // ---------------------------------------------------------------------------------
  35.  
  36. CGWorldPane::~CGWorldPane()
  37. {
  38. }
  39.  
  40.  
  41. // ---------------------------------------------------------------------------------
  42. //        • SetGWorld
  43. // ---------------------------------------------------------------------------------
  44. void
  45. CGWorldPane::SetGWorld (GWorldPtr inGW)
  46. {
  47.     mGW = inGW;
  48.     Refresh ();
  49. }
  50.  
  51.  
  52. // ---------------------------------------------------------------------------------
  53. //        • DrawSelf
  54. // ---------------------------------------------------------------------------------
  55. void
  56. CGWorldPane::DrawSelf()
  57. {
  58.     Rect    theFrame;
  59.  
  60.     CalcLocalFrameRect( theFrame );
  61.     ::InsetRect (&theFrame, 2, 2);
  62.  
  63.     StColorState::Normalize();    // also wanted by CopyBits
  64.     ::EraseRect (&theFrame);
  65.  
  66.     if (mGW) {
  67.         PixMapHandle    thePM;
  68.         thePM = ::GetGWorldPixMap (mGW);
  69.         
  70.         Rect    theDisplayRect;
  71.         theDisplayRect = (**thePM).bounds;
  72.     
  73.         PL_Utils::FitRect (&theDisplayRect, theFrame);
  74.         PL_Utils::CenterRect (&theDisplayRect, theFrame);
  75.         
  76.         ::CopyBits ((BitMap*)*thePM, &GetMacPort()->portBits,
  77.                     &(**thePM).bounds, &theDisplayRect, srcCopy, nil);
  78.     }
  79. }
  80.